<?php
namespace app\we\controller;
use think\Controller;
use app\we\sdk\Thinkwechat;


class Space extends Controller{


   
    public function index($openid=''){
        $fans=model('we/WeFans')->info($openid);
        $cfo=model('we/WeFansCfo')->info($openid);
        $printerFans=model('printer/PrinterFans')->info($openid);
        $this->assign('fans',$fans);
        $this->assign('cfo',$cfo);
      	$this->assign('printerFans',$printerFans);
        return $this->fetch();
      
    }

     public function amount($openid=''){
        $fans=model('we/WeFans')->info($openid);
        $map['openid']=$openid;
        $map['type']=0;
        $map['status']=['egt',0];
        $logs=db('WeFansCfoLog')->where($map)->select();
       
        $this->assign('logs',$logs);
        $this->assign('fans',$fans);
        
        return $this->fetch();
      
    }

     public function score($openid=''){
        $fans=model('we/WeFans')->info($openid);
        $map['openid']=$openid;
        $map['type']=1;
        $map['status']=['egt',0];
        $db=db('WeFansCfoLog');
        $logs=$db->where($map)->select();
      
        $this->assign('logs',$logs);
        $this->assign('fans',$fans);
        return $this->fetch();
      
    }

    public function edit($openid=''){
      $fans=model('we/WeFans')->info($openid);
      
      if(request()->isPost()){
        $data=input('post.');
        $data['birthday']=strtotime($data['birthday']);
        $res=db('WeFans')->where('openid',$openid)->update($data);
        if ($res)$this->success('成功');
      }else{
        $this->assign('openid',$openid);
        $this->assign('fans',$fans);
        return $this->fetch();
      }
    }


}